<?php
$this->pageTitle=$model->title;
$this->breadcrumbs=array(
    $model->title,
);
if(Yii::app()->user->checkAccess('admin')) {
$this->menu=array(
    array('label'=>Yii::t('site','Item'), 'items'=>array(
        array('label'=>Yii::t('site','Update Post'), 'url'=>array('update', 'id'=>$model->id)),
        array('label'=>Yii::t('site','Export as SQL Script'), 'url'=>array('exportDBChangeScript', 'id'=>$model->id)),
        array('label'=>Yii::t('site','Delete Post'), 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this post?')),
    )),
    array('label'=>Yii::t('site','All Items'),'items'=>array(
        array('label'=>Yii::t('site','Create New Post'), 'url'=>array('create')),
        array('label'=>Yii::t('site','List Posts'), 'url'=>array('index')),
        array('label'=>Yii::t('site','Manage Posts'), 'url'=>array('admin')),
    )),
);
}
?>

<?php $this->renderPartial('_view', array(
    'data'=>$model,
)); ?>

<div id="comments">
    <?php if($model->commentCount>=1): ?>
    <h3>
        <?php echo $model->commentCount>1 ? $model->commentCount . ' comments' : 'One comment'; ?>
    </h3>

    <?php $this->renderPartial('_comments',array(
        'post'=>$model,
        'comments'=>$model->comments,
    )); ?>
    <?php endif; ?>

    <h4><?php echo CHtml::encode(Yii::t('site','Leave a Comment')); ?></h4>

    <?php if(Yii::app()->user->hasFlash('commentSubmitted')): ?>
        <div class="flash-success">
            <?php echo Yii::app()->user->getFlash('commentSubmitted'); ?>
        </div>
    <?php else: ?>
        <?php $this->renderPartial('/comment/_form',array(
            'model'=>$comment,
        )); ?>
    <?php endif; ?>

</div><!-- comments -->
